package com.pay.cloud.activity;

import android.content.Intent;
import android.os.Bundle;

import com.pay.cloud.DataFactory;
import com.pay.cloud.KeyInfo;
import com.pay.cloud.R;
import com.pay.cloud.fragment.DomainFragment;

import static com.pay.cloud.KeyInfo.KEY_CANCEL;
import static com.pay.cloud.KeyInfo.KEY_ENTER;
import static com.pay.cloud.KeyInfo.KEY_NUM_1;
import static com.pay.cloud.KeyInfo.KEY_NUM_2;
import static com.pay.cloud.KeyInfo.KEY_NUM_3;
import static com.pay.cloud.KeyInfo.KEY_NUM_4;

public class DomainActivity extends AbstractActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_domain);
        String curDomain = DataFactory.getDataStore().getServerUrl();
        setMainFragment(new DomainFragment(curDomain));
    }

    @Override
    public boolean onKeyDown(KeyInfo keyInfo) {
        if (keyInfo == KEY_ENTER || keyInfo == KEY_CANCEL) {
            Intent intent = new Intent(this, SettingActivity.class);
            startActivity(intent);
        } else {
            if (keyInfo == KEY_NUM_1) {
                setMainFragment(new DomainFragment(0));
            } else if (keyInfo == KEY_NUM_2) {
                setMainFragment(new DomainFragment(1));
            } else if (keyInfo == KEY_NUM_3) {
                setMainFragment(new DomainFragment(2));
            } else if (keyInfo == KEY_NUM_4) {
                setMainFragment(new DomainFragment(3));
            }
        }
        return false;
    }

}
